import request from "@/utils/service"

// 上传文件
export const uploadFileAPI = (data: FormData) => {
  return request.post("/common/upload", data)
}

// 添加菜品
export const addDishAPI = (data: any) => {
  return request.post<any, any>("/dish", data)
}

// 获取菜品列表
export const getDishListAPI = ({ page, pageSize, name, categoryId, status }: any) => {
  return request.get<any, any>(
    `/dish/page?page=${page}&pageSize=${pageSize}${name ? `&name=${name}` : ""}${categoryId ? `&categoryId=${categoryId}` : ""}${status ? `&status=${status}` : ""}`
  )
}

// 批量删除菜品
export const deleteDishAPI = (ids: string) => {
  return request.delete<any, any>(`/dish?ids=${ids}`)
}

// 获取菜品详情
export const getDishDetailAPI = (id: number) => {
  return request.get<any, any>(`/dish/${id}`)
}

// 更新菜品信息
export const updateDishAPI = (data: any) => {
  return request.put<any, any>("/dish", data)
}

// 修改菜品状态
export const changeDishStatusAPI = (id: number, status: string) => {
  return request.post<any, any>(`/dish/status/${status}?id=${id}`)
}
